<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>服务器部署项目-cnblog | 凌歆的博客</title>
    <meta name="generator" content="VuePress 1.9.5">
    <link rel="icon" href="/img/favicon.ico">
    <meta name="description" content="web前端技术博客,专注web前端学习与总结。JavaScript,js,ES6,TypeScript,vue,React,python,css3,html5,Node,git,github等技术文章。">
    <meta name="keywords" content="前端博客,个人技术博客,前端,前端开发,前端框架,web前端,前端面试题,技术文档,学习,面试,JavaScript,js,ES6,TypeScript,vue,python,css3,html5,Node,git,github,markdown">
    <meta name="baidu-site-verification" content="7F55weZDDc">
    <meta name="theme-color" content="#11a8cd">
    
    <link rel="preload" href="/assets/css/0.styles.d9c8cf8c.css" as="style"><link rel="preload" href="/assets/js/app.57550e13.js" as="script"><link rel="preload" href="/assets/js/2.f014c35f.js" as="script"><link rel="preload" href="/assets/js/182.5fab25cc.js" as="script"><link rel="prefetch" href="/assets/js/10.03a98811.js"><link rel="prefetch" href="/assets/js/100.145e708e.js"><link rel="prefetch" href="/assets/js/101.098ca5c8.js"><link rel="prefetch" href="/assets/js/102.4d45c69a.js"><link rel="prefetch" href="/assets/js/103.499de505.js"><link rel="prefetch" href="/assets/js/104.c2c1b9b6.js"><link rel="prefetch" href="/assets/js/105.4e9b0663.js"><link rel="prefetch" href="/assets/js/106.9bb8cf6f.js"><link rel="prefetch" href="/assets/js/107.a81b32d7.js"><link rel="prefetch" href="/assets/js/108.81511e67.js"><link rel="prefetch" href="/assets/js/109.6a6741bf.js"><link rel="prefetch" href="/assets/js/11.e8729182.js"><link rel="prefetch" href="/assets/js/110.de657fe7.js"><link rel="prefetch" href="/assets/js/111.b092af6d.js"><link rel="prefetch" href="/assets/js/112.2dca5709.js"><link rel="prefetch" href="/assets/js/113.dbed1fac.js"><link rel="prefetch" href="/assets/js/114.e95a0131.js"><link rel="prefetch" href="/assets/js/115.2e3e8285.js"><link rel="prefetch" href="/assets/js/116.e64f7fec.js"><link rel="prefetch" href="/assets/js/117.583552c9.js"><link rel="prefetch" href="/assets/js/118.aa5d18f0.js"><link rel="prefetch" href="/assets/js/119.0c7b52d7.js"><link rel="prefetch" href="/assets/js/12.d63acec2.js"><link rel="prefetch" href="/assets/js/120.13f86281.js"><link rel="prefetch" href="/assets/js/121.e2b5b7f9.js"><link rel="prefetch" href="/assets/js/122.5252216a.js"><link rel="prefetch" href="/assets/js/123.8b8a3503.js"><link rel="prefetch" href="/assets/js/124.60df855c.js"><link rel="prefetch" href="/assets/js/125.f073ab1c.js"><link rel="prefetch" href="/assets/js/126.7b73de6a.js"><link rel="prefetch" href="/assets/js/127.4e25971c.js"><link rel="prefetch" href="/assets/js/128.0edf0e06.js"><link rel="prefetch" href="/assets/js/129.5cb5a70a.js"><link rel="prefetch" href="/assets/js/13.2259ef71.js"><link rel="prefetch" href="/assets/js/130.00247fda.js"><link rel="prefetch" href="/assets/js/131.d6fc003a.js"><link rel="prefetch" href="/assets/js/132.1a32b18f.js"><link rel="prefetch" href="/assets/js/133.e46c0193.js"><link rel="prefetch" href="/assets/js/134.a6ad681f.js"><link rel="prefetch" href="/assets/js/135.2fcbe137.js"><link rel="prefetch" href="/assets/js/136.f69bf451.js"><link rel="prefetch" href="/assets/js/137.b9ef2fcc.js"><link rel="prefetch" href="/assets/js/138.7fdd9feb.js"><link rel="prefetch" href="/assets/js/139.a3a37c91.js"><link rel="prefetch" href="/assets/js/14.0d6b23b9.js"><link rel="prefetch" href="/assets/js/140.a7c013ae.js"><link rel="prefetch" href="/assets/js/141.956c36ce.js"><link rel="prefetch" href="/assets/js/142.5aacfe42.js"><link rel="prefetch" href="/assets/js/143.57d691ef.js"><link rel="prefetch" href="/assets/js/144.b1e5766e.js"><link rel="prefetch" href="/assets/js/145.463284b7.js"><link rel="prefetch" href="/assets/js/146.6cc6420c.js"><link rel="prefetch" href="/assets/js/147.5b78c5a2.js"><link rel="prefetch" href="/assets/js/148.8d1d7679.js"><link rel="prefetch" href="/assets/js/149.4e0eb213.js"><link rel="prefetch" href="/assets/js/15.f6fde69d.js"><link rel="prefetch" href="/assets/js/150.b183de37.js"><link rel="prefetch" href="/assets/js/151.729ae770.js"><link rel="prefetch" href="/assets/js/152.b1297018.js"><link rel="prefetch" href="/assets/js/153.bb991bca.js"><link rel="prefetch" href="/assets/js/154.6f2286aa.js"><link rel="prefetch" href="/assets/js/155.6a9c7e4d.js"><link rel="prefetch" href="/assets/js/156.f7bd535d.js"><link rel="prefetch" href="/assets/js/157.64c0065c.js"><link rel="prefetch" href="/assets/js/158.d31ae949.js"><link rel="prefetch" href="/assets/js/159.7daea8a7.js"><link rel="prefetch" href="/assets/js/16.7be21beb.js"><link rel="prefetch" href="/assets/js/160.33cc971a.js"><link rel="prefetch" href="/assets/js/161.1676442a.js"><link rel="prefetch" href="/assets/js/162.71378046.js"><link rel="prefetch" href="/assets/js/163.99e49959.js"><link rel="prefetch" href="/assets/js/164.306f07d2.js"><link rel="prefetch" href="/assets/js/165.170977c7.js"><link rel="prefetch" href="/assets/js/166.f8602525.js"><link rel="prefetch" href="/assets/js/167.eea5c001.js"><link rel="prefetch" href="/assets/js/168.0146a311.js"><link rel="prefetch" href="/assets/js/169.05f9c9d9.js"><link rel="prefetch" href="/assets/js/17.2543f471.js"><link rel="prefetch" href="/assets/js/170.25d602b2.js"><link rel="prefetch" href="/assets/js/171.1ada26a6.js"><link rel="prefetch" href="/assets/js/172.2a0f697c.js"><link rel="prefetch" href="/assets/js/173.230d8ca8.js"><link rel="prefetch" href="/assets/js/174.e3758a2b.js"><link rel="prefetch" href="/assets/js/175.0f19f8ea.js"><link rel="prefetch" href="/assets/js/176.bf70d37d.js"><link rel="prefetch" href="/assets/js/177.4400f272.js"><link rel="prefetch" href="/assets/js/178.85af7b89.js"><link rel="prefetch" href="/assets/js/179.4cfaaaa2.js"><link rel="prefetch" href="/assets/js/18.394415f8.js"><link rel="prefetch" href="/assets/js/180.449c8409.js"><link rel="prefetch" href="/assets/js/181.73276924.js"><link rel="prefetch" href="/assets/js/183.ecd4934d.js"><link rel="prefetch" href="/assets/js/184.246092cf.js"><link rel="prefetch" href="/assets/js/185.c671cd86.js"><link rel="prefetch" href="/assets/js/186.49bd1963.js"><link rel="prefetch" href="/assets/js/187.1fb32764.js"><link rel="prefetch" href="/assets/js/188.7c6885e9.js"><link rel="prefetch" href="/assets/js/189.a8701dec.js"><link rel="prefetch" href="/assets/js/19.ca7db8ea.js"><link rel="prefetch" href="/assets/js/190.ae3d3bde.js"><link rel="prefetch" href="/assets/js/191.ad7cd44e.js"><link rel="prefetch" href="/assets/js/192.bc443842.js"><link rel="prefetch" href="/assets/js/193.e4755764.js"><link rel="prefetch" href="/assets/js/194.814112ce.js"><link rel="prefetch" href="/assets/js/195.1c0aaa80.js"><link rel="prefetch" href="/assets/js/196.a6bd7add.js"><link rel="prefetch" href="/assets/js/20.4e91cd31.js"><link rel="prefetch" href="/assets/js/21.f095e6e1.js"><link rel="prefetch" href="/assets/js/22.72f4b8ab.js"><link rel="prefetch" href="/assets/js/23.e94eb9d2.js"><link rel="prefetch" href="/assets/js/24.0eae7d6f.js"><link rel="prefetch" href="/assets/js/25.36157609.js"><link rel="prefetch" href="/assets/js/26.dc5b6cba.js"><link rel="prefetch" href="/assets/js/27.c19b7b63.js"><link rel="prefetch" href="/assets/js/28.3aceae59.js"><link rel="prefetch" href="/assets/js/29.536091b3.js"><link rel="prefetch" href="/assets/js/3.d11119c4.js"><link rel="prefetch" href="/assets/js/30.821a4a30.js"><link rel="prefetch" href="/assets/js/31.5238784c.js"><link rel="prefetch" href="/assets/js/32.10bc7179.js"><link rel="prefetch" href="/assets/js/33.c1ed69c9.js"><link rel="prefetch" href="/assets/js/34.8d384231.js"><link rel="prefetch" href="/assets/js/35.d8890e52.js"><link rel="prefetch" href="/assets/js/36.eca37ad5.js"><link rel="prefetch" href="/assets/js/37.802549e3.js"><link rel="prefetch" href="/assets/js/38.53841770.js"><link rel="prefetch" href="/assets/js/39.7ae44409.js"><link rel="prefetch" href="/assets/js/4.493b9bca.js"><link rel="prefetch" href="/assets/js/40.ce56364a.js"><link rel="prefetch" href="/assets/js/41.85f0114b.js"><link rel="prefetch" href="/assets/js/42.714da6e2.js"><link rel="prefetch" href="/assets/js/43.fee4437c.js"><link rel="prefetch" href="/assets/js/44.b039b68b.js"><link rel="prefetch" href="/assets/js/45.96a55605.js"><link rel="prefetch" href="/assets/js/46.956ffb03.js"><link rel="prefetch" href="/assets/js/47.147d9218.js"><link rel="prefetch" href="/assets/js/48.ff787b40.js"><link rel="prefetch" href="/assets/js/49.871eee87.js"><link rel="prefetch" href="/assets/js/5.e0ba07d7.js"><link rel="prefetch" href="/assets/js/50.99b7c29e.js"><link rel="prefetch" href="/assets/js/51.8ecbf4ba.js"><link rel="prefetch" href="/assets/js/52.53d91d7e.js"><link rel="prefetch" href="/assets/js/53.af8a0d2a.js"><link rel="prefetch" href="/assets/js/54.a2f848b5.js"><link rel="prefetch" href="/assets/js/55.267e9947.js"><link rel="prefetch" href="/assets/js/56.0b201c40.js"><link rel="prefetch" href="/assets/js/57.cbdfd6f7.js"><link rel="prefetch" href="/assets/js/58.636c0c3f.js"><link rel="prefetch" href="/assets/js/59.fc9216c4.js"><link rel="prefetch" href="/assets/js/6.b98373f2.js"><link rel="prefetch" href="/assets/js/60.34f16fc4.js"><link rel="prefetch" href="/assets/js/61.4d130bd8.js"><link rel="prefetch" href="/assets/js/62.927caa10.js"><link rel="prefetch" href="/assets/js/63.a451fee0.js"><link rel="prefetch" href="/assets/js/64.32a5d47b.js"><link rel="prefetch" href="/assets/js/65.bc099429.js"><link rel="prefetch" href="/assets/js/66.3953050d.js"><link rel="prefetch" href="/assets/js/67.e934823b.js"><link rel="prefetch" href="/assets/js/68.4bcb52b0.js"><link rel="prefetch" href="/assets/js/69.bede18c8.js"><link rel="prefetch" href="/assets/js/7.8de8df2d.js"><link rel="prefetch" href="/assets/js/70.fce1daac.js"><link rel="prefetch" href="/assets/js/71.ea0a8c5d.js"><link rel="prefetch" href="/assets/js/72.15382c9e.js"><link rel="prefetch" href="/assets/js/73.848364d3.js"><link rel="prefetch" href="/assets/js/74.5fd08a50.js"><link rel="prefetch" href="/assets/js/75.c937c70d.js"><link rel="prefetch" href="/assets/js/76.a0dacd5a.js"><link rel="prefetch" href="/assets/js/77.4019cc23.js"><link rel="prefetch" href="/assets/js/78.9676a9e1.js"><link rel="prefetch" href="/assets/js/79.e46e10d5.js"><link rel="prefetch" href="/assets/js/8.2098eb96.js"><link rel="prefetch" href="/assets/js/80.987e83cb.js"><link rel="prefetch" href="/assets/js/81.eb98ff36.js"><link rel="prefetch" href="/assets/js/82.623561a7.js"><link rel="prefetch" href="/assets/js/83.e256d909.js"><link rel="prefetch" href="/assets/js/84.7d06a550.js"><link rel="prefetch" href="/assets/js/85.b8d9879e.js"><link rel="prefetch" href="/assets/js/86.31c4581b.js"><link rel="prefetch" href="/assets/js/87.e06ee05e.js"><link rel="prefetch" href="/assets/js/88.81ef718d.js"><link rel="prefetch" href="/assets/js/89.ba237d2f.js"><link rel="prefetch" href="/assets/js/9.36092fd0.js"><link rel="prefetch" href="/assets/js/90.ad2c9d92.js"><link rel="prefetch" href="/assets/js/91.a661f52d.js"><link rel="prefetch" href="/assets/js/92.1c28035b.js"><link rel="prefetch" href="/assets/js/93.c8b8e3d6.js"><link rel="prefetch" href="/assets/js/94.b6bc4a44.js"><link rel="prefetch" href="/assets/js/95.92cea882.js"><link rel="prefetch" href="/assets/js/96.5373491b.js"><link rel="prefetch" href="/assets/js/97.bb39efc8.js"><link rel="prefetch" href="/assets/js/98.af7a030f.js"><link rel="prefetch" href="/assets/js/99.07dc87d8.js">
    <link rel="stylesheet" href="/assets/css/0.styles.d9c8cf8c.css">
  </head>
  <body class="theme-mode-light">
    <div id="app" data-server-rendered="true"><div class="theme-container sidebar-open have-rightmenu"><header class="navbar blur"><div title="目录" class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="https://lingxin-tanhua.oss-cn-shanghai.aliyuncs.com/QQ%E6%88%AA%E5%9B%BE20220503092755.png" alt="凌歆的博客" class="logo"> <span class="site-name can-hide">凌歆的博客</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="前端" class="dropdown-title"><a href="/web/" class="link-title">前端</a> <span class="title" style="display:none;">前端</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>学习笔记</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/note/html/" class="nav-link">HTML笔记</a></li><li class="dropdown-subitem"><a href="/note/js-low/" class="nav-link">JavaScript基础笔记</a></li><li class="dropdown-subitem"><a href="/note/js-high/" class="nav-link">JavaScript高阶笔记</a></li><li class="dropdown-subitem"><a href="/note/js-dom-bom/" class="nav-link">JavaScript DOM和BOM笔记</a></li><li class="dropdown-subitem"><a href="/note/jquery/" class="nav-link">jQuery笔记</a></li><li class="dropdown-subitem"><a href="/note/ajax/" class="nav-link">Ajax笔记</a></li><li class="dropdown-subitem"><a href="/note/nodejs/" class="nav-link">NodeJs笔记</a></li><li class="dropdown-subitem"><a href="/note/reg/" class="nav-link">正则表达式笔记</a></li><li class="dropdown-subitem"><a href="/note/vue/" class="nav-link">Vue笔记</a></li><li class="dropdown-subitem"><a href="/note/react/" class="nav-link">react笔记</a></li><li class="dropdown-subitem"><a href="/note/wx/" class="nav-link">微信小程序笔记</a></li><li class="dropdown-subitem"><a href="/note/uniapp/" class="nav-link">uniapp笔记</a></li><li class="dropdown-subitem"><a href="/note/echarts/" class="nav-link">echarts笔记</a></li><li class="dropdown-subitem"><a href="/note/git/" class="nav-link">Git笔记</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="后端" class="dropdown-title"><a href="/back/" class="link-title">后端</a> <span class="title" style="display:none;">后端</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/note/java/" class="nav-link">JAVA</a></li><li class="dropdown-item"><!----> <a href="/note/javaweb/" class="nav-link">JavaWeb</a></li><li class="dropdown-item"><!----> <a href="/note/mysql/" class="nav-link">MySql</a></li><li class="dropdown-item"><!----> <a href="/note/ssm/" class="nav-link">ssm</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="算法" class="dropdown-title"><a href="/algor/" class="link-title">算法</a> <span class="title" style="display:none;">算法</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/note/sf/" class="nav-link">算法训练营</a></li><li class="dropdown-item"><!----> <a href="/note/js-sf/" class="nav-link">js数据结构与算法</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="面试" class="dropdown-title"><a href="/mianshi/" class="link-title">面试</a> <span class="title" style="display:none;">面试</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/note/lqb/" class="nav-link">蓝桥杯备战</a></li><li class="dropdown-item"><!----> <a href="/note/ms/" class="nav-link">前端面试</a></li><li class="dropdown-item"><!----> <a href="/note/hmms/" class="nav-link">黑马面试</a></li><li class="dropdown-item"><!----> <a href="/note/xzms/" class="nav-link">校招零距离面试</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="解决方案" class="dropdown-title"><a href="/resolve/" class="link-title">解决方案</a> <span class="title" style="display:none;">解决方案</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/note/qd-resolve/" class="nav-link">前端解决方案</a></li><li class="dropdown-item"><!----> <a href="/note/hd-resolve/" class="nav-link">后端解决方案</a></li></ul></div></div><div class="nav-item"><a href="/pages/beb6c0bd8a66cea6/" class="nav-link">收藏</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="索引" class="dropdown-title"><a href="/archives/" class="link-title">索引</a> <span class="title" style="display:none;">索引</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/" class="nav-link">分类</a></li><li class="dropdown-item"><!----> <a href="/tags/" class="nav-link">标签</a></li><li class="dropdown-item"><!----> <a href="/archives/" class="nav-link">归档</a></li></ul></div></div> <a href="https://github.com/linxin1123/vuepress-blog" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <div class="sidebar-hover-trigger"></div> <aside class="sidebar" style="display:none;"><div class="blogger"><img src="https://lingxin-tanhua.oss-cn-shanghai.aliyuncs.com/QQ%E6%88%AA%E5%9B%BE20220503092755.png"> <div class="blogger-info"><h3>lingxin</h3> <span>凌歆</span></div></div> <nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="前端" class="dropdown-title"><a href="/web/" class="link-title">前端</a> <span class="title" style="display:none;">前端</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>学习笔记</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/note/html/" class="nav-link">HTML笔记</a></li><li class="dropdown-subitem"><a href="/note/js-low/" class="nav-link">JavaScript基础笔记</a></li><li class="dropdown-subitem"><a href="/note/js-high/" class="nav-link">JavaScript高阶笔记</a></li><li class="dropdown-subitem"><a href="/note/js-dom-bom/" class="nav-link">JavaScript DOM和BOM笔记</a></li><li class="dropdown-subitem"><a href="/note/jquery/" class="nav-link">jQuery笔记</a></li><li class="dropdown-subitem"><a href="/note/ajax/" class="nav-link">Ajax笔记</a></li><li class="dropdown-subitem"><a href="/note/nodejs/" class="nav-link">NodeJs笔记</a></li><li class="dropdown-subitem"><a href="/note/reg/" class="nav-link">正则表达式笔记</a></li><li class="dropdown-subitem"><a href="/note/vue/" class="nav-link">Vue笔记</a></li><li class="dropdown-subitem"><a href="/note/react/" class="nav-link">react笔记</a></li><li class="dropdown-subitem"><a href="/note/wx/" class="nav-link">微信小程序笔记</a></li><li class="dropdown-subitem"><a href="/note/uniapp/" class="nav-link">uniapp笔记</a></li><li class="dropdown-subitem"><a href="/note/echarts/" class="nav-link">echarts笔记</a></li><li class="dropdown-subitem"><a href="/note/git/" class="nav-link">Git笔记</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="后端" class="dropdown-title"><a href="/back/" class="link-title">后端</a> <span class="title" style="display:none;">后端</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/note/java/" class="nav-link">JAVA</a></li><li class="dropdown-item"><!----> <a href="/note/javaweb/" class="nav-link">JavaWeb</a></li><li class="dropdown-item"><!----> <a href="/note/mysql/" class="nav-link">MySql</a></li><li class="dropdown-item"><!----> <a href="/note/ssm/" class="nav-link">ssm</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="算法" class="dropdown-title"><a href="/algor/" class="link-title">算法</a> <span class="title" style="display:none;">算法</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/note/sf/" class="nav-link">算法训练营</a></li><li class="dropdown-item"><!----> <a href="/note/js-sf/" class="nav-link">js数据结构与算法</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="面试" class="dropdown-title"><a href="/mianshi/" class="link-title">面试</a> <span class="title" style="display:none;">面试</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/note/lqb/" class="nav-link">蓝桥杯备战</a></li><li class="dropdown-item"><!----> <a href="/note/ms/" class="nav-link">前端面试</a></li><li class="dropdown-item"><!----> <a href="/note/hmms/" class="nav-link">黑马面试</a></li><li class="dropdown-item"><!----> <a href="/note/xzms/" class="nav-link">校招零距离面试</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="解决方案" class="dropdown-title"><a href="/resolve/" class="link-title">解决方案</a> <span class="title" style="display:none;">解决方案</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/note/qd-resolve/" class="nav-link">前端解决方案</a></li><li class="dropdown-item"><!----> <a href="/note/hd-resolve/" class="nav-link">后端解决方案</a></li></ul></div></div><div class="nav-item"><a href="/pages/beb6c0bd8a66cea6/" class="nav-link">收藏</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="索引" class="dropdown-title"><a href="/archives/" class="link-title">索引</a> <span class="title" style="display:none;">索引</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/" class="nav-link">分类</a></li><li class="dropdown-item"><!----> <a href="/tags/" class="nav-link">标签</a></li><li class="dropdown-item"><!----> <a href="/archives/" class="nav-link">归档</a></li></ul></div></div> <a href="https://github.com/linxin1123/vuepress-blog" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav>  <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>学习笔记</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>前端解决方案</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>后端解决方案</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/pages/8f2477/" class="sidebar-link">idea配置-cnblog</a></li><li><a href="/pages/bb494d/" class="sidebar-link">number类型id和String类型id处理-cnblog</a></li><li><a href="/pages/5ba6b5/" class="sidebar-link">spring-data-redis-cnblog</a></li><li><a href="/pages/7702c5/" class="sidebar-link">不使用docker部署项目需要启动的一些服务-cnblog</a></li><li><a href="/pages/8b9d6f/" class="sidebar-link">订单处理-cnblog</a></li><li><a href="/pages/8501f1/" aria-current="page" class="active sidebar-link">服务器部署项目-cnblog</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level2"><a href="/pages/8501f1/#_2-项目部署" class="sidebar-link">2. 项目部署</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level3"><a href="/pages/8501f1/#_2-1-手动部署项目" class="sidebar-link">2.1 手动部署项目</a></li><li class="sidebar-sub-header level3"><a href="/pages/8501f1/#_2-2-基于shell脚本自动部署" class="sidebar-link">2.2 基于Shell脚本自动部署</a></li><li class="sidebar-sub-header level4"><a href="/pages/8501f1/#_2-2-1-介绍" class="sidebar-link">2.2.1 介绍</a></li><li class="sidebar-sub-header level4"><a href="/pages/8501f1/#_2-2-2-推送代码到远程" class="sidebar-link">2.2.2 推送代码到远程</a></li><li class="sidebar-sub-header level4"><a href="/pages/8501f1/#_2-2-3-git操作" class="sidebar-link">2.2.3 Git操作</a></li><li class="sidebar-sub-header level4"><a href="/pages/8501f1/#_2-2-4-maven安装" class="sidebar-link">2.2.4 Maven安装</a></li><li class="sidebar-sub-header level4"><a href="/pages/8501f1/#_2-2-5-shell脚本准备" class="sidebar-link">2.2.5 Shell脚本准备</a></li><li class="sidebar-sub-header level4"><a href="/pages/8501f1/#_2-2-6-linux权限" class="sidebar-link">2.2.6 Linux权限</a></li><li class="sidebar-sub-header level4"><a href="/pages/8501f1/#_2-2-7-授权并执行脚本" class="sidebar-link">2.2.7 授权并执行脚本</a></li><li class="sidebar-sub-header level4"><a href="/pages/8501f1/#_2-2-8-设置静态ip" class="sidebar-link">2.2.8 设置静态IP</a></li></ul></li></ul></li><li><a href="/pages/b19544/" class="sidebar-link">过滤器实现登录拦截-cnblog</a></li><li><a href="/pages/4401ce/" class="sidebar-link">全局异常处理解决重复添加同一用户-cnblog</a></li><li><a href="/pages/5b3d96/" class="sidebar-link">事务管理-cnblog</a></li><li><a href="/pages/a8797f/" class="sidebar-link">文件上传解决方案-cnblog</a></li><li><a href="/pages/cf8e8d/" class="sidebar-link">线程变量-cnblog</a></li><li><a href="/pages/642c41/" class="sidebar-link">修改表时先删除后添加思想-cnblog</a></li><li><a href="/pages/d3f82f/" class="sidebar-link">自动化redis-cache-cnblog</a></li></ul></section></li></ul> </aside> <div><main class="page"><div class="theme-vdoing-wrapper "><div class="articleInfo-wrap" data-v-06225672><div class="articleInfo" data-v-06225672><ul class="breadcrumbs" data-v-06225672><li data-v-06225672><a href="/" title="首页" class="iconfont icon-home router-link-active" data-v-06225672></a></li> <li data-v-06225672><a href="/resolve/#解决方案" data-v-06225672>解决方案</a></li><li data-v-06225672><a href="/resolve/#后端解决方案" data-v-06225672>后端解决方案</a></li></ul> <div class="info" data-v-06225672><div title="作者" class="author iconfont icon-touxiang" data-v-06225672><a href="https://github.com/linxin1123" target="_blank" title="作者" class="beLink" data-v-06225672>lingxin</a></div> <div title="创建时间" class="date iconfont icon-riqi" data-v-06225672><a href="javascript:;" data-v-06225672>2023-02-17</a></div> <!----></div></div></div> <!----> <div class="content-wrapper"><div class="right-menu-wrapper"><div class="right-menu-margin"><div class="right-menu-title">目录</div> <div class="right-menu-content"></div></div></div> <h1><img src="">服务器部署项目-cnblog<!----></h1>  <div class="theme-vdoing-content content__default"><h2 id="_2-项目部署"><a href="#_2-项目部署" class="header-anchor">#</a> 2. 项目部署</h2> <p>之前我们讲解Linux操作系统时，就提到，我们服务端开发工程师学习Linux系统的目的就是将来我们开发的项目绝大部分情况下都需要部署在Linux系统中。那么在本章节，我们将通过两种方式，来演示项目部署，分别是：手动部署项目 和 基于shell脚本自动部署。</p> <h3 id="_2-1-手动部署项目"><a href="#_2-1-手动部署项目" class="header-anchor">#</a> 2.1 手动部署项目</h3> <p><strong>1). 在IDEA中开发SpringBoot项目并打成jar包</strong></p> <p>项目是一个很简单的springboot项目(可以自己开发一个，也可以直接导入资料中提供的)，结构如下：</p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115739196-2048448842.png" alt="image-20210815102934678"></p> <p>可以在本地的idea中先启动当前的demo工程，然后访问一下，看看工程是否正常访问。</p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115738131-184459643.png" alt="image-20210815103130325"></p> <p>执行package指令，进行打包操作，将当前的springboot项目，打成一个jar包。</p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115737770-666060842.png" alt="image-20210815103344378"></p> <p><strong>2). 将jar包上传到Linux服务器</strong></p> <p>通过 rz 指令，将打好的jar包上传至Linux服务器的 /usr/local/app 目录下。 先执行指令创建app目录。</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>A. 在/usr/local下创建目录app
mkdir /usr/local/app

B. 切换到app目录下
cd /usr/local/app

C. 执行指令,进行jar包上传
rz
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115737271-1808054164.png" alt="image-20210815131101930"></p> <p>此时这个jar包就上传到 /usr/local/app 目录了。</p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115735913-1096691481.png" alt="image-20210815131234243"></p> <p><strong>3). 启动SpringBoot程序</strong></p> <p>由于我们的项目已经打成jar包上传上来到Linux服务器，我们只需要运行这个jar包项目就启动起来了，所以只需要执行如下指令即可：</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>java -jar helloworld-1.0-SNAPSHOT.jar
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115734964-892832966.png" alt="image-20210815131812582"></p> <p>==注意： 由于前面安装的Tomcat在启动时，会占用端口号8080，而当前springboot项目我们没有配置端口号，默认也是8080，所以我们要想启动springboot项目，需要把之前运行的Tomcat停止掉。==</p> <p><strong>4). 检查防火墙，确保8080端口对外开放，访问SpringBoot项目</strong></p> <div class="language- line-numbers-mode"><pre class="language-text"><code>firewall-cmd --zone=public --list-ports
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115726720-1522276432.png" alt="image-20210815132430385"></p> <p>如果防火墙没有放开8080端口，还需要放开对应的端口号，执行如下指令：</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>firewall-cmd --zone=public --add-port=8080/tcp --permanent
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p><strong>5). 访问测试</strong></p> <blockquote><p>http://192.168.138.130:8080/hello</p></blockquote> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115654837-1389020581.png" alt="image-20210815132748655"></p> <p><strong>6). 后台运行项目</strong></p> <p>当前这个demo工程我们已经部署成功了，并且我们也可以访问项目了。但是这个工程目前是存在问题的，就是当前我们项目启动的这个窗口被霸屏占用了，如果我们把这个窗口关闭掉(或ctrl+c)，当前服务也就访问不到了，我们可以试一下。</p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115723407-567008975.png" alt="image-20210815133510405"></p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115712426-1107479932.png" alt="image-20210815133719642"></p> <p><strong>目前程序运行的问题：</strong></p> <p>A. 线上程序不会采用控制台霸屏的形式运行程序，而是将程序在后台运行</p> <p>B. 线上程序不会将日志输出到控制台，而是输出到日志文件，方便运维查阅信息</p> <p><strong>后台运行程序:</strong></p> <p>要想让我们部署的项目进行后台运行，这个时候我们需要使用到linux中的一个命令 nohup ，接下来，就来介绍一下nohup命令。</p> <blockquote><p>**nohup命令：**英文全称 no hang up（不挂起），用于不挂断地运行指定命令，退出终端不会影响程序的运行</p> <p><strong>语法格式：</strong> nohup Command [ Arg … ] [&amp;]</p> <p><strong>参数说明：</strong></p> <p>​	Command：要执行的命令</p> <p>​	Arg：一些参数，可以指定输出文件</p> <p>​	&amp;：让命令在后台运行</p> <p><strong>举例：</strong></p> <p>​	nohup java -jar boot工程.jar &amp;&gt; hello.log &amp;</p> <p>​	上述指令的含义为： 后台运行 java -jar 命令，并将日志输出到hello.log文件</p></blockquote> <p>那么经过上面的介绍，我们可以推测中，我们要想让当前部署的项目后台运行，就可以使用下面的指令：</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>nohup java -jar helloworld-1.0-SNAPSHOT.jar &amp;&gt; hello.log &amp;
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115711995-1857100364.png" alt="image-20210815140847083"></p> <p>这样的话，我们的项目就已经启动成功了，我们可以通过ps指令，查看到系统的进程。</p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115711524-389423901.png" alt="image-20210815140944635"></p> <p>接下来，我们再次访问我们的项目，来看看服务是否可用。</p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115654837-1389020581.png" alt="image-20210815132748655"></p> <p><strong>7). 停止SpringBoot项目</strong></p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115710635-902141543.png" alt="image-20210815142132135"></p> <h3 id="_2-2-基于shell脚本自动部署"><a href="#_2-2-基于shell脚本自动部署" class="header-anchor">#</a> 2.2 基于Shell脚本自动部署</h3> <h4 id="_2-2-1-介绍"><a href="#_2-2-1-介绍" class="header-anchor">#</a> 2.2.1 介绍</h4> <p>前面介绍的项目部署是手动部署，也就是部署过程中的每一步操作都需要我们手动操作。接下来，我们需要再讲解一下项目的自动部署，从而来简化项目部署的操作，那么我们先来整体上了解一下项目自动部署的流程及操作步骤。</p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115709582-1171402330.png" alt=""></p> <p>操作步骤如下：</p> <p>1). 在Gitee上创建远程仓库，并将本地的项目代码推送到远程仓库中</p> <p>2). 在Linux中安装Git,克隆代码</p> <p>3). 在Linux中安装maven</p> <p>4). 编写Shell脚本（拉取代码、编译、打包、启动）</p> <p>5). 为用户授予执行Shell脚本的权限</p> <p>6). 执行Shell脚本</p> <h4 id="_2-2-2-推送代码到远程"><a href="#_2-2-2-推送代码到远程" class="header-anchor">#</a> 2.2.2 推送代码到远程</h4> <p>这部分操作，大家只需要参考之前讲解的Git，来完成helloworld工程代码推送即可。</p> <p>A. 创建远程仓库</p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115708072-853159368.png" alt=""></p> <p>B. 将idea中的代码提交并推送到远程仓库</p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115707601-306440055.png" alt="image-20210815145253347"></p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115706873-1684013932.png" alt=""></p> <h4 id="_2-2-3-git操作"><a href="#_2-2-3-git操作" class="header-anchor">#</a> 2.2.3 Git操作</h4> <p>1). Git软件安装</p> <p>通过yum命令在线安装git，执行如下指令：</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>yum list git			列出git安装包
yum install git			在线安装git
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>通过上述指令，安装好git之后，我们就可以通过 git --version去验证git的环境。</p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115706454-1705193826.png" alt="image-20210815145934265"></p> <p>2). Git克隆代码</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>cd /usr/local/
git clone https://gitee.com/ChuanZhiBoKe/helloworld.git
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115705829-1573250369.png" alt="image-20210815150452988"></p> <h4 id="_2-2-4-maven安装"><a href="#_2-2-4-maven安装" class="header-anchor">#</a> 2.2.4 Maven安装</h4> <p>由于我们的工程是maven工程，我们要想进行项目的编译打包，需要用到maven的指令，所以需要安装maven。具体操作步骤如下：</p> <p><strong>1). 上传资料中提供的maven的安装包</strong></p> <p>通过rz指令上传课程资料中的maven安装包</p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115705202-713812256.png" alt="image-20210815151544489"></p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115704772-1791882404.png" alt=""></p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115704215-172668800.png" alt="image-20210815151901262"></p> <p><strong>2). 解压maven安装包到/usr/local目录</strong></p> <div class="language- line-numbers-mode"><pre class="language-text"><code>tar -zxvf apache-maven-3.5.4-bin.tar.gz -C /usr/local
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115703683-1017000081.png" alt="image-20210815152033246"></p> <p><strong>3). 在/etc/profile配置文件中配置环境变量</strong></p> <div class="language- line-numbers-mode"><pre class="language-text"><code>vim /etc/profile

修改配置文件，进入到命令模式，按G切换到最后一行，按a/i/o进入插入模式，然后在最后加入如下内容 :
export MAVEN_HOME=/usr/local/apache-maven-3.5.4
export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH

然后按ESC进入到命令模式，输入 :wq 保存并退出
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115703056-1470969720.png" alt="image-20210815152321369"></p> <p>要想让配置的环境变量生效,还需要执行如下指令:</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>source /etc/profile
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115702503-1657013235.png" alt="image-20210815152616703"></p> <p><strong>4). 修改maven的settings.xml配置文件,配置本地仓库地址</strong></p> <p>A. 切换目录</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>cd /usr/local/apache-maven-3.5.4/conf
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>B. 编辑settings.xml配置文件</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>vim settings.xml
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>在其中增加如下配置,配置本地仓库地址:</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>&lt;localRepository&gt;/usr/local/repo&lt;/localRepository&gt;
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115701922-1883354292.png" alt="image-20210815152936129"></p> <p>并在settings.xml中的<code>&lt;mirrors&gt;</code>标签中,配置阿里云的私服(==选做==):</p> <div class="language-xml line-numbers-mode"><pre class="language-xml"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>mirror</span><span class="token punctuation">&gt;</span></span> 
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>id</span><span class="token punctuation">&gt;</span></span>alimaven<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>id</span><span class="token punctuation">&gt;</span></span> 
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>mirrorOf</span><span class="token punctuation">&gt;</span></span>central<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>mirrorOf</span><span class="token punctuation">&gt;</span></span> 
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>name</span><span class="token punctuation">&gt;</span></span>aliyun maven<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>name</span><span class="token punctuation">&gt;</span></span> 
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>url</span><span class="token punctuation">&gt;</span></span>http://maven.aliyun.com/nexus/content/groups/public/<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>url</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>mirror</span><span class="token punctuation">&gt;</span></span> 
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115701108-812262206.png" alt="image-20210815170915170"></p> <h4 id="_2-2-5-shell脚本准备"><a href="#_2-2-5-shell脚本准备" class="header-anchor">#</a> 2.2.5 Shell脚本准备</h4> <blockquote><p>Shell脚本（shell script），是一种Linux系统中的脚本程序。使用Shell脚本编程跟 JavaScript、Java编程一样，只要有一个能编写代码的文本编辑器和一个能解释执行的脚本解释器就可以了。</p> <p>对于Shell脚本编写不作为本课程重点内容，直接使用课程资料中提供的脚本文件bootStart.sh即可。</p></blockquote> <p>在/usr/local/目录下创建一个目录 sh(mkdir sh)，并将shell脚本上传到该目录下。或者直接在sh目录下创建一个脚本bootStart.sh，然后将资料中的bootStart.sh文件打开,内容拷贝过来即可。</p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115700366-2079937878.png" alt="image-20210815153759071"></p> <p><strong>脚本解读:</strong></p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115659172-1856717097.png" alt="image-20210815154943654"></p> <h4 id="_2-2-6-linux权限"><a href="#_2-2-6-linux权限" class="header-anchor">#</a> 2.2.6 Linux权限</h4> <p>前面我们已经把Shell脚本准备好了，但是Shell脚本要想正常的执行，还需要给Shell脚本分配执行权限。 由于linux系统是一个多用户的操作系统，并且针对每一个用户，Linux会严格的控制操作权限。接下来，我们就需要介绍一下Linux系统的权限控制。</p> <blockquote><p>1). ==chmod==（英文全拼：change mode）命令是控制用户对文件的权限的命令</p> <p>2). Linux中的权限分为三种 ：读(r)、写(w)、执行(x)</p> <p>3). Linux文件权限分为三级 : 文件所有者（Owner）、用户组（Group）、其它用户（Other Users）</p> <p>4). 只有文件的所有者和超级用户可以修改文件或目录的权限</p> <p>5). 要执行Shell脚本需要有对此脚本文件的执行权限(x)，如果没有则不能执行</p></blockquote> <p>Linux系统中权限描述如下:</p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115658131-1583817496.png" alt="image-20210815162945754"></p> <p>解析当前脚本的权限情况:</p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115657654-468469685.png" alt=""></p> <p>chmod命令可以使用八进制数来指定权限(0 - 代表无 , 1 - 执行x , 2 - 写w , 4 - 读r):</p> <table><thead><tr><th>值</th> <th>权限</th> <th>rwx</th></tr></thead> <tbody><tr><td>7</td> <td>读 + 写 + 执行</td> <td>rwx</td></tr> <tr><td>6</td> <td>读 + 写</td> <td>rw-</td></tr> <tr><td>5</td> <td>读 + 执行</td> <td>r-x</td></tr> <tr><td>4</td> <td>只读</td> <td>r--</td></tr> <tr><td>3</td> <td>写 + 执行</td> <td>-wx</td></tr> <tr><td>2</td> <td>只写</td> <td>-w-</td></tr> <tr><td>1</td> <td>只执行</td> <td>--x</td></tr> <tr><td>0</td> <td>无</td> <td>---</td></tr></tbody></table> <p><strong>举例:</strong></p> <div class="language- line-numbers-mode"><pre class="language-text"><code>chmod 777 bootStart.sh   为所有用户授予读、写、执行权限
chmod 755 bootStart.sh   为文件拥有者授予读、写、执行权限，同组用户和其他用户授予读、执行权限
chmod 210 bootStart.sh   为文件拥有者授予写权限，同组用户授予执行权限，其他用户没有任何权限
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>==注意:==</p> <p>三个数字分别代表不同用户的权限</p> <ul><li>第1位表示文件拥有者的权限</li> <li>第2位表示同组用户的权限</li> <li>第3位表示其他用户的权限</li></ul> <h4 id="_2-2-7-授权并执行脚本"><a href="#_2-2-7-授权并执行脚本" class="header-anchor">#</a> 2.2.7 授权并执行脚本</h4> <p>在测试阶段，我们可以给所有的人都赋予执行该shell脚本的权限。所以可以执行如下指令：</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>chmod 777 bootStart.sh
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115656919-1608598304.png" alt="image-20210815163957647"></p> <p>权限解读:</p> <p>A. 第一个7，代表当前文件所有者root用户，对该文件具有读写执行权限；</p> <p>B. 第二个7，代表当前文件所有者所属组的用户，对该文件具有读写执行权限；</p> <p>B. 第三个7，代表其他用户，对该文件具有读写执行权限；</p> <p>执行该shell脚本:</p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115656413-482523358.png" alt="image-20210815170334935"></p> <p>==注意： 在执行maven指令进行打包时，第一次执行可能会耗时比较长，因为在进行maven工程的打包时，需要到中央仓库下载工程依赖的jar包和插件(可以在settings.xml中配置阿里云私服加速下载)。==</p> <p>启动完成之后, 我们可以查看java进程：</p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115655269-729118309.png" alt="image-20210815170418707"></p> <p>访问项目：</p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115654837-1389020581.png" alt="image-20210815132748655"></p> <h4 id="_2-2-8-设置静态ip"><a href="#_2-2-8-设置静态ip" class="header-anchor">#</a> 2.2.8 设置静态IP</h4> <p>我们目前安装的Linux操作系统，安装完毕之后并没有配置IP地址，默认IP地址是动态获取的，那如果我们使用该Linux服务器部署项目，IP动态获取的话，也就意味着，IP地址可能会发生变动，那我们访问项目的话就会非常繁琐，所以作为服务器，我们一般还需要把IP地址设置为静态的。</p> <p>1). 设置静态IP</p> <p>设置静态ip，我们就需要修改 /etc/sysconfig/network-scripts/ifcfg-ens33 配置文件，内容如下：</p> <div class="language-properties line-numbers-mode"><pre class="language-properties"><code><span class="token key attr-name">TYPE</span><span class="token punctuation">=</span><span class="token value attr-value">Ethernet</span>
<span class="token key attr-name">PROXY_METHOD</span><span class="token punctuation">=</span><span class="token value attr-value">none</span>
<span class="token key attr-name">BROWSER_ONLY</span><span class="token punctuation">=</span><span class="token value attr-value">no</span>
<span class="token key attr-name">BOOTPROTO</span><span class="token punctuation">=</span><span class="token value attr-value">static</span>
<span class="token key attr-name">IPADDR</span><span class="token punctuation">=</span><span class="token value attr-value">&quot;192.168.138.100&quot;        # 设置的静态IP地址</span>
<span class="token key attr-name">NETMASK</span><span class="token punctuation">=</span><span class="token value attr-value">&quot;255.255.255.0&quot;         # 子网掩码</span>
<span class="token key attr-name">GATEWAY</span><span class="token punctuation">=</span><span class="token value attr-value">&quot;192.168.138.2&quot;         # 网关地址</span>
<span class="token key attr-name">DNS1</span><span class="token punctuation">=</span><span class="token value attr-value">&quot;192.168.138.2&quot;            # DNS服务器</span>
<span class="token key attr-name">DEFROUTE</span><span class="token punctuation">=</span><span class="token value attr-value">yes</span>
<span class="token key attr-name">IPV4_FAILURE_FATAL</span><span class="token punctuation">=</span><span class="token value attr-value">no</span>
<span class="token key attr-name">IPV6INIT</span><span class="token punctuation">=</span><span class="token value attr-value">yes</span>
<span class="token key attr-name">IPV6_AUTOCONF</span><span class="token punctuation">=</span><span class="token value attr-value">yes</span>
<span class="token key attr-name">IPV6_DEFROUTE</span><span class="token punctuation">=</span><span class="token value attr-value">yes</span>
<span class="token key attr-name">IPV6_FAILURE_FATAL</span><span class="token punctuation">=</span><span class="token value attr-value">no</span>
<span class="token key attr-name">IPV6_ADDR_GEN_MODE</span><span class="token punctuation">=</span><span class="token value attr-value">stable-privacy</span>
<span class="token key attr-name">NAME</span><span class="token punctuation">=</span><span class="token value attr-value">ens33</span>
<span class="token key attr-name">UUID</span><span class="token punctuation">=</span><span class="token value attr-value">afd0baa3-8bf4-4e26-8d20-5bc426b75fd6</span>
<span class="token key attr-name">DEVICE</span><span class="token punctuation">=</span><span class="token value attr-value">ens33</span>
<span class="token key attr-name">ONBOOT</span><span class="token punctuation">=</span><span class="token value attr-value">yes</span>
<span class="token key attr-name">ZONE</span><span class="token punctuation">=</span><span class="token value attr-value">public</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br></div></div><p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115654349-1995052193.png" alt="image-20210815171934667"></p> <p>上述我们所设置的网段为138，并不是随意指定的，需要和我们虚拟机中的虚拟网络编辑器中的NAT模式配置的网关保持一致。</p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115653167-1939907375.png" alt="image-20210815172303896"></p> <p>2). 重启网络服务</p> <p>ip地址修改完毕之后，需要重启网络服务，执行如下指令：</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>systemctl restart network
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115652571-1093782448.png" alt="image-20210815172448448"></p> <p>==注意：重启完网络服务后ip地址已经发生了改变，此时FinalShell已经连接不上Linux系统，需要创建一个新连接才能连接到Linux。==</p> <p>再次连接上Linux之后，我们再次查看IP地址，就可以看到我们所设置的静态IP：</p> <p><img src="https://img2023.cnblogs.com/blog/3089561/202302/3089561-20230217115651605-259737612.png" alt="image-20210815172832108"></p></div></div>  <div class="page-edit"><div class="edit-link"><a href="https://github.com/linxin1123/vuepress-blog/edit/master/docs/09.解决方案/02.后端解决方案/06.服务器部署项目-cnblog.md" target="_blank" rel="noopener noreferrer">编辑</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <!----> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">2023/02/17, 12:26:44</span></div></div> <div class="page-nav-wapper"><div class="page-nav-centre-wrap"><a href="/pages/8b9d6f/" class="page-nav-centre page-nav-centre-prev"><div class="tooltip">订单处理-cnblog</div></a> <a href="/pages/b19544/" class="page-nav-centre page-nav-centre-next"><div class="tooltip">过滤器实现登录拦截-cnblog</div></a></div> <div class="page-nav"><p class="inner"><span class="prev">
        ←
        <a href="/pages/8b9d6f/" class="prev">订单处理-cnblog</a></span> <span class="next"><a href="/pages/b19544/">过滤器实现登录拦截-cnblog</a>→
      </span></p></div></div></div> <div class="article-list"><div class="article-title"><a href="/archives/" class="iconfont icon-bi">最近更新</a></div> <div class="article-wrapper"><dl><dd>01</dd> <dt><a href="/pages/0b785d/"><div>
            Vuex
            <!----></div></a> <span class="date">03-14</span></dt></dl><dl><dd>02</dd> <dt><a href="/pages/c59cc0/"><div>
            Vue响应式原理
            <!----></div></a> <span class="date">03-14</span></dt></dl><dl><dd>03</dd> <dt><a href="/pages/83cc7a/"><div>
            Vue虚拟DOM-cnblog
            <!----></div></a> <span class="date">03-14</span></dt></dl> <dl><dd></dd> <dt><a href="/archives/" class="more">更多文章&gt;</a></dt></dl></div></div></main></div> <div class="footer"><div class="icons"><a href="3010733382@qq.com" title="发邮件" target="_blank" class="iconfont icon-youjian"></a><a href="https://github.com/linxin1123" title="GitHub" target="_blank" class="iconfont icon-github"></a><a href="https://music.163.com/#/playlist?id=755597173" title="听音乐" target="_blank" class="iconfont icon-erji"></a></div> 
  Theme by
  <a href="https://github.com/xugaoyi/vuepress-theme-vdoing" target="_blank" title="本站主题">Vdoing</a> 
    | Copyright © 2022-2023
    <span>lingxin | <a href="https://github.com/linxin1123/vuepress-blog/blob/master/LICENSE" target="_blank">MIT License</a></span></div> <div class="buttons"><div title="返回顶部" class="button blur go-to-top iconfont icon-fanhuidingbu" style="display:none;"></div> <div title="去评论" class="button blur go-to-comment iconfont icon-pinglun" style="display:none;"></div> <div title="主题模式" class="button blur theme-mode-but iconfont icon-zhuti"><ul class="select-box" style="display:none;"><li class="iconfont icon-zidong">
          跟随系统
        </li><li class="iconfont icon-rijianmoshi">
          浅色模式
        </li><li class="iconfont icon-yejianmoshi">
          深色模式
        </li><li class="iconfont icon-yuedu">
          阅读模式
        </li></ul></div></div> <!----> <!----> <!----></div><div class="global-ui"><div></div></div></div>
    <script src="/assets/js/app.57550e13.js" defer></script><script src="/assets/js/2.f014c35f.js" defer></script><script src="/assets/js/182.5fab25cc.js" defer></script>
  </body>
</html>
